<?php
$this->load->view('common/header',
array(
  'title' =>'添加店铺'
));
$this->load->view('common/sliderbar',
array(
  'menu'   => 'shop',
  'option' => 'shopadd'
));
 ?>

	<div class="main-content">
	<div class="breadcrumbs" id="breadcrumbs">
		<ul class="breadcrumb">
			<li>
        <a>店铺管理</a>
			</li>
		</ul>
	</div>
	<div class="page-content">
		<div class="page-header">
			<h1>添加店铺</h1>
		</div>
		<!-- /.page-header -->

	</div>
  <div class="row">
    <div class="col-xs-12">

  <form class="form-horizontal" action="/shop/shop_add_go" method="post">
    <div class="form-group">
      <label class="col-sm-3 control-label no-padding-right" for="shopname">店名</label>
      <div class="col-sm-9">
        <input type="text" id="shopname" class="col-xs-10 col-sm-2" name="shopname">
      </div>
    </div>
    <div class="form-group">
      <label class="col-sm-3 control-label no-padding-right" for="shopboss">老板娘</label>
      <div class="col-sm-9">
        <input type="text" id="shopboss" class="col-xs-10 col-sm-1" name="shopboss">
      </div>
    </div>
    <div class="form-group">
      <label class="col-sm-3 control-label no-padding-right" for="shoptel">联系电话</label>
      <div class="col-sm-9">
        <input type="text" id="shoptel" class="col-xs-10 col-sm-2" name="shoptel">
      </div>
    </div>
    <div class="form-group">
      <label class="col-sm-3 control-label no-padding-right" for="shopbrand">合作品牌</label>
      <div class="col-sm-9">
              <span class="J_selectbranditem">未选择品牌</span>
              <a href="javascript:;" style="line-height:27px;" class="selectbrand">选择品牌</a>
      </div>
    </div>
    <div class="form-group">
      <label class="col-sm-3 control-label no-padding-right" for="shopotherbrand">其他公司品牌</label>
      <div class="col-sm-9">
        <input type="text" id="shopotherbrand" class="col-xs-10 col-sm-3" name="shopotherbrand">
      </div>
    </div>
    <div class="form-group">
      <label class="col-sm-3 control-label no-padding-right" for="shopinfo">店内信息</label>
      <div class="col-sm-9">
        <textarea name="shopinfo" id="shopinfo" rows="4" cols="80" style="resize:none;"></textarea>
        <!-- <input type="text" id="shopinfo" class="col-xs-10 col-sm-5" name="shopinfo"> -->
      </div>
    </div>
    <div class="form-group">
      <label class="col-sm-3 control-label no-padding-right" for="shopconsignee">收货人</label>
      <div class="col-sm-9">
        <input type="text" id="shopconsignee" class="col-xs-10 col-sm-1" name="shopconsignee">
      </div>
    </div>
    <div class="form-group">
      <label class="col-sm-3 control-label no-padding-right" for="shopctel">收货人电话</label>
      <div class="col-sm-9">
        <input type="text" id="shopctel" class="col-xs-10 col-sm-2" name="shopctel">
      </div>
    </div>
    <div class="form-group">
      <label class="col-sm-3 control-label no-padding-right" for="shopaddr">地址</label>
      <div class="col-sm-9">
        <input type="text" id="shopaddr" class="col-xs-10 col-sm-5" name="shopaddr">
      </div>
    </div>
    <div class="form-group">
      <input type="button" onclick="shop_add()" class="btn btn-primary btn-lg" style="margin-left: 40%; margin-top:20px; display: block; padding-top: 3px; padding-bottom: 3px;" value="添  加">
    </div>
  </form>
  </div>
  </div>

  </form>
  </div>
	<script type="text/javascript" src="../public/js/shopbranditem/shopbranditem.js"></script>
  <script type="text/javascript">
    var shop_add = function(){
      var flag = true;
      $('input:not([type=button]),#shopid,#bid').each(function(index, el) {
        if($(this).val()==''){
          $(this).css('border', '3px solid #f77');
					flag = false;
          alert('请将信息补充完整');
					return false;
        }
        $(this).attr('style', ' ');
      });
			if(flag == false){
				return false;
			}
      if(window.brandcount.length==0){
        alert('请选择品牌');
        $('.selectbrand').css('border', '3px solid #f77');
        return false;
      }
      var bid = '';
      for (var i = 0; i < window.brandcount.length; i++) {
        if(window.brandcount[i]){
          bid = bid+','+window.brandcount[i];
        }
      }
      bid = bid.replace(',','');
      var bname = '';
      for (var i = 0; i < window.brandnamecount.length; i++) {
        if(window.brandnamecount[i]){
          bname = bname+','+window.brandnamecount[i];
        }
      }
      bname = bname.replace(',','');
      // console.log($('.form-horizontal').serialize());
      var postdata = {
        shopname:$('#shopname').val(),
        shopboss:$('#shopboss').val(),
        shoptel:$('#shoptel').val(),
        shopbrand:bid,
        shopbrandname:bname,
        shopotherbrand:$('#shopotherbrand').val(),
        shopinfo:$('#shopinfo').val(),
        shopconsignee:$('#shopconsignee').val(),
        shopctel:$('#shopctel').val(),
        shopaddr:$('#shopaddr').val()
      }
      $.post('/shop/shop_add_go',postdata, function(data) {
        if(data!='false'){
          alert('添加成功');
        }else{
          alert('添加失败');
        }
      });
    }
  </script>
	<?php
$this->load->view('common/footer');
?>
